package com.gel.codegeneration.service;

import com.gel.codegeneration.model.dto.req.chathistory.ChatHistoryQueryRequest;
import com.gel.codegeneration.model.entity.User;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.service.IService;
import com.gel.codegeneration.model.entity.ChatHistory;
import dev.langchain4j.memory.ChatMemory;

import java.time.LocalDateTime;

/**
 * 对话历史 服务层。
 *
 * @author <a>gel</a>
 */
public interface ChatHistoryService extends IService<ChatHistory> {
    boolean addChatMessage(Long appId,String message,String messageType,Long userId);

    //关联删除（删除应用时删除会话记忆）
    boolean deleteByAppId(Long appId);
    //构建查询包装类
    QueryWrapper getQueryWrapper(ChatHistoryQueryRequest chatHistoryQueryRequest);

    int loadChatHistoryToMemory(Long appId, ChatMemory chatMemory, int maxCount);

    //游标查询会话历史
    Page<ChatHistory> listAppChatHistoryByPage(Long appId, Integer pageSize, LocalDateTime lastUpdateTime, User loginUser);
}
